package com.xiaolin.util;

import java.util.Stack;

/**
 * @ClassName TestStack
 * @Description TODO
 * @Detail detail
 * @Author MyPC
 * @Date 2020/9/27
 * @Version 1.0
 */
public class TestStack {
    public static void main(String[] args) {
        Stack<Integer> stack=new Stack<>();
        //向栈顶添加元素
        stack.add(1);
        stack.add(2);
        stack.add(3);
        stack.add(4);
        //查看栈顶的值
        System.out.println(stack.peek());
        //弹出栈顶的值
        System.out.println(stack.pop());
        System.out.println(stack.peek());
        //先栈顶添加元素
        System.out.println(stack.push(8));
        System.out.println(stack.peek());
    }
}
